package com.xb.cloud.merchant.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.xb.cloud.common.constant.DbConstants;
import com.xb.cloud.merchant.service.client.MerchantService;
import com.xb.cloud.product.service.business.model.Merchant;
import com.xb.cloud.product.service.business.model.mapper.MerchantMapper;
import com.xb.cloud.service.client.ServiceReturnInfo;
import com.xb.cloud.service.client.ServiceReturnUtils;

@Service
public class MerchantServiceImpl implements MerchantService {

	@Resource
	MerchantMapper merchantMapper;

	@Override
	public ServiceReturnInfo isValidMerchant(Long merchantId) {
		Merchant merchant = merchantMapper.selectByPrimaryKey(merchantId);
		if (merchant == null) {
			return ServiceReturnUtils.success(false);
		}
		if (DbConstants.isTrue(merchant.getIsDeleted()) || !DbConstants.isTrue(merchant.getIsEnabled())) {
			return ServiceReturnUtils.success(false);
		}
		return ServiceReturnUtils.success(true);
	}

}
